package com.sky.mapper.user;

import com.sky.pojo.AddressBook;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface AddressBookMapper {

    @Select("select * from address_book where user_id=#{userId} ")
    List<AddressBook> getAllAddress(Long userId);

    void save(AddressBook addressBook);

    @Select("select * from address_book where id=#{id}")
    AddressBook getAddressById(Long id);

    void updateAddressById(AddressBook addressBook);

    @Update("update address_book set is_default=#{isDefault} where user_id=#{userId}")
    void setDefaultAddress(AddressBook addressBook);

    @Delete("delete from address_book where id=#{id}")
    void deleteById(Long id);

    AddressBook getDefaultAddress(AddressBook addressBook);
}
